<?php

/**
 * This is the model class for table "{{menu}}".
 *
 * The followings are the available columns in table '{{menu}}':
 * @property double $id
 * @property string $ename
 * @property string $cname
 * @property double $parentid
 * @property string $m
 * @property string $c
 * @property string $a
 * @property string $data
 * @property double $listorder
 * @property string $display
 * @property string $comment
 * @property double $disabled
 */
class Menu extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Menu the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{menu}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('parentid, listorder, disabled', 'numerical'),
			array('ename, cname', 'length', 'max'=>40),
			array('m, c', 'length', 'max'=>20),
			array('a', 'length', 'max'=>50),
			array('data', 'length', 'max'=>100),
			array('display', 'length', 'max'=>7),
			array('comment', 'length', 'max'=>4000),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, ename, cname, parentid, m, c, a, data, listorder, display, comment, disabled', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'ename' => 'Ename',
			'cname' => 'Cname',
			'parentid' => 'Parentid',
			'm' => 'M',
			'c' => 'C',
			'a' => 'A',
			'data' => 'Data',
			'listorder' => 'Listorder',
			'display' => 'Display',
			'comment' => 'Comment',
			'disabled' => 'Disabled',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('ename',$this->ename,true);
		$criteria->compare('cname',$this->cname,true);
		$criteria->compare('parentid',$this->parentid);
		$criteria->compare('m',$this->m,true);
		$criteria->compare('c',$this->c,true);
		$criteria->compare('a',$this->a,true);
		$criteria->compare('data',$this->data,true);
		$criteria->compare('listorder',$this->listorder);
		$criteria->compare('display',$this->display,true);
		$criteria->compare('comment',$this->comment,true);
		$criteria->compare('disabled',$this->disabled);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}